home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c-part1 / 2598 < prev    next >
Encoding:
Internet Message Format  |  1996-08-05  |  1.3 KB

  1. Path: news.ov.com!news
  2. From: glenn@ov.com (Fletcher.Glenn@ov.com)
  3. Newsgroups: comp.lang.c
  4. Subject: Re: Segmentation fault at return statement. C
  5. Date: 22 Jan 1996 18:05:09 GMT
  6. Organization: OpenVision
  7. Message-ID: <4e0jkl$e80@spanky.pls.ov.com>
  8. References: <4dm2n1$egk@murphy.servtech.com>
  9. Reply-To: glenn@ov.com
  10. NNTP-Posting-Host: foghorn.pls.ov.com
  11.  
  12. In article egk@murphy.servtech.com, Avijit Dasgupta <avi@servtech.com> writes:
  13. >Hi all,
  14. >
  15. >I am not being able to figure out why I get a segmentation fault in 
  16. >a return stmt. 
  17. >
  18. >main.c:
  19. >
  20. >main()
  21. >{
  22. >...
  23. >...
  24. > calls a function test() returning int
  25. >
  26. >}
  27. >
  28. >test.c:
  29. >
  30. >test()
  31. >{
  32. >
  33. >..
  34. >...
  35. >..
  36. >83: return(999); <----- Segmentation fault at this stmt.
  37. >}
  38. >
  39. >Running dbx I get these error messages:
  40. >
  41. >(dbx) where
  42. >=> [1] test( ) at line 83
  43. >dbx: bad data address
  44. >dbx fetch at 0x697075a4 failed - I/O error
  45. >dbx : attempt to read stack failed - bad frame pointer
  46. >(dbx)
  47. >
  48. >I can't figure out, bcoz this function gets called multiple times and
  49. >fails only after a fixed X times ... Any Help ? 
  50. >
  51.  
  52.  
  53. There is insufficient information here to make a diagnosis.  I can, however,
  54. guess that you are stomping data in the stack, perhaps by using more than
  55. the allocated space for some of your automatic variables.  Perhaps you 
  56. are using an array of ints, and stepping off the end of the array?
  57.  
  58.             Fletcher.Glenn@ov.com
  59.  
  60.  
  61.